/* Project eeprom_2550_osc
PIC16F628A
*/

#include <pic.h>

__CONFIG(
PWRTEN
& BORDIS
& UNPROTECT
& WDTDIS
& LVPDIS
& HS
);
__IDLOC(F628);

#define CK RB0

#define SW2 RB2
#define SW3 RB3
#define SW4 RB4

unsigned int i, N;


void interrupt entry(void){

if(TMR1IF){
N++;

if(SW2){
if(N > 742){
N = 0;
CK = 1;

for(i=0; i<2500; i++){
TMR0 = 0;
while(TMR0 < 255);
}

CK = 0;
}
TMR1H = 158; TMR1L = 114;
}

if(SW2 && SW3){
if(N > 118){
N = 0;
CK = 1;

for(i=0; i<2500; i++){
TMR0 = 0;
while(TMR0 < 255);
}

CK = 0;
}
TMR1H = 158; TMR1L = 198;
}

if(SW4){
CK = 1;

for(i=0; i<2500; i++){
TMR0 = 0;
while(TMR0 < 255);
}

CK = 0;
}

TMR1IF = 0;
}
}



void main(void){

CMCON = 0b00000111;
T1CON = 0b00110001;
PIE1 = 0b00000001;
INTCON = 0b01000000;
TMR1IF = 0;
ei();

OPTION = 0b10000000;

PORTA = 0;
TRISA = 0b00000000;
PORTB = 0;
TRISB = 0b00011100;

N = 0; CK = 0;


while(1){
}
}